package cn.wjc.core.event;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/event")
public class EventController {

    @Autowired
    private ApplicationEventPublisher applicationEventPublisher;

    @GetMapping("/coupon/{message}")
    public void publish(@PathVariable String message) {
        log.debug("[coupon] start.");
        applicationEventPublisher.publishEvent(new CouponEvent(message));
        log.debug("[coupon] end.");
    }
}
